#ifndef __TIMER_B_H_
#define __TIMER_B_H_

#include "common_def.h"

// TBCLK = ACLK = 32768Hz
// timer b is used for executing a task after some period.
// Note: this function executes in interrupt context.

typedef void (*TIMERB_TASK_T)(void);

void timerb_init(void);

// Schedule a task after some period.
// A tick is 1/32768 second.
bool timerb_schedule(uint16 ticks_later, TIMERB_TASK_T task);
bool timerb_is_active(void);
void timerb_get_values(uint16* current, uint16* timeout);

#endif // __TIMER_B_H_
